mui.init({
	swipeBack: true
})
mui.plusReady(function() {
plus.webview.currentWebview().setStyle({
			top: '0',
			bottom: '0'
		})
})
var swith = false

if(localStorage.getItem("passwords")) {
	$('.password input').val(localStorage.getItem("passwords"))
}
if(localStorage.getItem("user")) {
	$('.phone input').val(localStorage.getItem("user"))
}
$(".logintap button").on("tap", function() {
	if(common.replace($('.phone input').val()) == '') {
		common.toast('账号不能为空')
		return
	}
	if(common.replace($('.password input').val()) == '') {
		common.toast('密码不能为空')
		return
	}
	if(swith) {
		return
	}
	swith = true
	common.ajax("/userCore/userLogin", {
			userName: $('.phone input').val(),
			password: $('.password input').val()
		},
		function(data) {
			swith = false
			if(data.code == 1) {
				localStorage.setItem('userData', JSON.stringify(data.data))
				$('input').blur()
				//加入购物车
				var list = plus.webview.getWebviewById("ylindex.html")
				mui.fire(list, 'shopPingCar');
				
				
				localStorage.setItem("passwords", $('.password input').val())
				localStorage.setItem("user", $('.phone input').val())

				var wvs, self, launch;
				wvs = plus.webview.all();
				self = plus.webview.currentWebview();
				launch = plus.webview.getLaunchWebview();
				for(var i = 0, len = wvs.length; i < len; i++) {
				var subpages = ['home.html', 'classify.html', 'special.html', 'shopping.html', 'my.html'];
					if(wvs[i].getURL() == self.getURL() || wvs[i].getURL() == launch.getURL() || subpages.indexOf(wvs[i])>=0) {
						continue
					}
					plus.webview.getWebviewById(wvs[i].id).reload()
				}
				plus.webview.close(plus.webview.currentWebview().id);
			} else {
				if(data.resultMsg) {
					common.toast(data.resultMsg)
				} else {
					console.log(data)
				}
			}
		})
})
var close = mui.back
mui.back = function() {
	close()
	$('input').blur()
}